﻿namespace MapleRock.P2PEmulator.Core
{
  using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Text;
  using System.Xml.Serialization;

  [XmlRoot("InputData")]
  public sealed class XmlInputData
  {
    [XmlAttribute("peersNumber")]
    public int PeersNumber { get; set; }

    [XmlAttribute("dimensions")]
    public int Dimensions { get; set; }

    [XmlAttribute("maxPeerLinksAllowed")]
    public int MaxPeerLinksAllowed { get; set; }

    [XmlAttribute("updDeliveryFailureProbability")]
    public double UpdDeliveryFailureProbability { get; set; }

    [XmlAttribute("infoSpaceBounds")]
    public string InfoSpaceBounds { get; set; }

    [XmlElement("Geography")]
    public XmlGeographyData[] Geography { get; set; }

    public static XmlInputData Load(string path)
    {
      var serializer = new XmlSerializer(typeof(XmlInputData));
      return (XmlInputData)serializer.Deserialize(File.Open(path, FileMode.Open));
    }
  }
}
